package com.ac.input.config;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.ac.input.dm.HndInpDefItm;
import com.ac.input.util.CompareOders;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright AgileCentury 2004</p>
 * <p>Company: AgileCentury</p>
 * @author <a href="mailto:lianzs@tom.com">Lianzs</a>
 * @version 1.0
 */

public class OrderClass implements Serializable {
	private static final long serialVersionUID = 1L;
	private List dmUnList = new ArrayList();
    private List dmList = new ArrayList();
    private String orderStr;

    public OrderClass() {}

    public OrderClass(List list) {
        for (int i = 0; i < list.size(); i++) {
            HndInpDefItm dm = (HndInpDefItm) list.get(i);
            if (!"0".equals(dm.getOrdTyp())) {
                dmList.add(dm);
            } else {
                dmUnList.add(dm);
            }
        }
        java.util.Collections.sort(dmList, new CompareOders());

        orderStr = "";
        if (dmList.size() > 0) {
            for (int i = 0; i < dmList.size(); i++) {
                HndInpDefItm dm = (HndInpDefItm) dmList.get(i);
                if ("1".equals(dm.getOrdTyp())) {
                    orderStr += dm.getColCode() + ",";
                } else if ("2".equals(dm.getOrdTyp())) {
                    orderStr += dm.getColCode() + " desc,";
                }
            }
            orderStr = orderStr.substring(0, orderStr.length() - 1);
        }
    }

    public List getChildren() {
        return dmList;
    }

    public List getDmUnList() {
        return dmUnList;
    }

    public String getOrderStr() {
        return orderStr;
    }
}
